package com.codemonkey.lq.qd.facotry.config.event;

import com.codemonkey.lq.qd.ServiceContext;
import com.codemonkey.lq.qd.facotry.config.ActionDefinition;
import com.codemonkey.lq.qd.facotry.config.ExecutionEvent;
import com.codemonkey.lq.qd.facotry.config.ServiceDefinition;

/**
 * 工厂模式.产生相应的EventObject
 * @author LQ
 *
 */
public final class ExecutionEventObjectFactory {
	public static ExecutionEvent getExecutionEvent(boolean isSuccess, Object source,
			ServiceContext sc) {
		if (source instanceof ActionDefinition) {
			return new ActionExecutionEvent(isSuccess, (ActionDefinition) source, sc);
		} else if (source instanceof ServiceDefinition) {
			return new ServiceExecutionEvent(isSuccess, (ServiceDefinition) source, sc);
		} else {
			throw new IllegalArgumentException("UNKOWN EVENT TYPE : " + source.toString());
		}
	}
}
